home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / testMac2NeXT.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  91 lines

  1. #import "MacToNeXTText.h"
  2. #import "common.h"
  3. #import <stdio.h>
  4.  
  5. void main()
  6. {
  7.     Instance    converter;
  8.     Integer    index;
  9.     Character    theChar, strictChar;
  10.     CString        source = "Hi there how are you doing?";
  11.     ErrorCode        errorone, errortwo;
  12.     FILE*    theFile;
  13.     CString    result, buffer;
  14.     Integer    resultsize;
  15.     Integer    ctr, colctr = 1;
  16.  
  17.     converter = [[MacToNeXTText alloc] init];
  18.     //
  19.     //    Convert an ascii char, an existing 8 bit char, and a characcter we know won't convert
  20.     //
  21.     printf("Character A: %c (bool result: %d)\n",
  22.         [converter ConvertCharacter: 'A'],
  23.         [converter GetBooleanFrom: SECOND_RESULT]);
  24.  
  25.     printf("Character paragraph: %c (bool result: %d)\n",
  26.         [converter ConvertCharacter: 0xA6],
  27.         [converter GetBooleanFrom: SECOND_RESULT]);
  28.  
  29.     printf("Can't convert apple : %c  (bool result: %d)\n",
  30.         [converter ConvertCharacter: 0xF0],
  31.         [converter GetBooleanFrom: SECOND_RESULT]);
  32.     for (index = 0; index < 256; index++)
  33.     {
  34.         theChar = [converter ConvertCharacter: index];
  35.         [converter UseIM1: YES];
  36.         errorone = [converter GetErrorCode];
  37.         strictChar = [converter ConvertCharacter: index];
  38.         [converter UseIM1: NO];
  39.         errortwo = [converter GetErrorCode];
  40.         printf("Converting Mac 0x%X to NeXT 0x%X (%c)  (error: %d) [strict: 0x%X (%c) (error: %d)]\n",
  41.             index,
  42.             theChar, theChar, errorone,
  43.             strictChar, strictChar, errortwo);
  44.     }
  45.  
  46.     // part two.
  47.     buffer = NewCString(512);
  48.     
  49.     for (ctr = 0; ctr < 256; ctr++)
  50.     {
  51.         if (colctr != 16)
  52.         {
  53.             buffer[ctr*2] = ctr;
  54.             buffer[(ctr*2)+1] = ' ';
  55.             colctr++;
  56.         }
  57.         else
  58.         {
  59.             buffer[ctr*2] = ctr;
  60.             buffer[(ctr*2)+1] = '\r';
  61.             colctr = 1;
  62.         }
  63.     }
  64.     buffer[512] = EndOfCString;
  65.     printf("Source text is: \n%s\n", &buffer[1]); // skip initial null
  66.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 512];
  67.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  68.     printf("Size of result: %d\n", resultsize);
  69.     printf("Results text is: \n");
  70.     for (ctr = 0; ctr < resultsize; ctr ++)
  71.         printf("%c", result[ctr]);
  72.     printf("\n");
  73.     //    test that it expands its internal buffer alright by giving it some text which we
  74.     //    know will multiply in size when it comes out. .. convert lots of apples
  75.     for (ctr = 0; ctr < 16; ctr++)
  76.         buffer[ctr] = 0xF0;
  77.     buffer[16] = EndOfCString;
  78.     printf("Source text is: \n%s\n", (CString)buffer);
  79.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 16];
  80.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  81.     printf("Size of result: %d\n", resultsize);
  82.     printf("Results text is: \n");
  83.     for (ctr = 0; ctr < resultsize; ctr ++)
  84.         printf("%c", result[ctr]);
  85.     printf("\n");
  86.     
  87.     FreePointer(result);
  88.     FreePointer(buffer);
  89.     close(theFile);
  90.     [converter    free];
  91. }